package com.goods.business.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class TimeUtils {
    //判断当前时间是否在今天
    public static boolean isToday(Date createTime) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
        try {
            Date day = simpleDateFormat.parse(simpleDateFormat.format(createTime));
            Date today = simpleDateFormat.parse(simpleDateFormat.format(new Date()));
            Calendar dayCalendar = Calendar.getInstance();
            dayCalendar.setTime(day);
            Calendar todayCalendar = Calendar.getInstance();
            todayCalendar.setTime(today);
            if (todayCalendar.equals(dayCalendar)) {
                return true;
            }
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return false;
    }
}
